<template>
  <div class="user" ref="wrapper">
    <div>
      <user-header :userInfo="userInfo"></user-header>
      <user-info :userInfo="userInfo"></user-info>
      <user-order></user-order>
      <div style="height: .01rem"></div>
    </div>
  <public-menu></public-menu>
  </div>
</template>

<script>
import axios from 'axios'
import Bscroll from 'better-scroll'
import UserHeader from './components/Header'
import UserInfo from './components/Info'
import UserOrder from './components/Order'
import PublicMenu from '../public/Menu'
export default {
  name: 'User',
  components: {
    UserHeader,
    UserInfo,
    UserOrder,
    PublicMenu
  },
  data () {
    return {
      userInfo: {}
    }
  },
  methods: {
    getInfo () {
      axios.get('/meimai/interface/member/getMemberData', {
        params: {
          'memberId': this.$store.state.userId
        }
      }).then((res) => {
        let datas = res.data
        // console.log(datas.data)
        if (datas.code === 0 && datas.data) {
          this.userInfo = datas.data
        }
      })
    },
    clickApp () {
      let ua = navigator.userAgent.toLowerCase()
      // console.log(ua)
      // let isWeiXin = () => { return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1 }
      // if (isWeiXin()) {
      //   alert('是')
      // } else {
      //   alert('不是')
      // }
      // Android终端
      // let isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
      // Ios终端
      // let isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
      if (isWeixinBrowser()) {
        alert('是isWeixinBrowser')
      } else {
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
          // Ios
          alert('是iOS')
        } else if (/(Android)/i.test(navigator.userAgent)) {
          // Android终端
          alert('是Android')
        }
      }
      function isWeixinBrowser () {
        return !!(/micromessenger/.test(ua))
      }
    }
  },
  mounted () {
    this.getInfo()
    this.scroll = new Bscroll(this.$refs.wrapper, {click: true})
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/mixins.styl'
  .user
    background-color: #f3f3f3
    position: absolute
    left: 0
    right: 0
    top: 0
    bottom: .98rem
</style>
